﻿#region Copyright

// Majesty of Omega - The next evolution of macro management space strategy
// 
// Copyright 2007-2009 André Claaßen
// 
// This file is protected by the terms and conditions of the
// Microsoft Community License (Ms-CL 1.1), a copy of which should
// have been distributed along with this software. If not,
// you may find the license information at the following URL:
// 
// http://www.microsoft.com/resources/sharedsource/licensingbasics/communitylicense.mspx

#endregion

#region

using System.Windows;
using Majesty_of_Omega.GUI.Controller;
using Majesty_of_Omega.Model.Game;

#endregion

namespace Majesty_of_Omega.GUI.Pages.Game.Research.Parts
{
    /// <summary>
    /// Interactionlogic for the UI of the Technology Matrix
    /// </summary>
    /// <remarks>
    /// The real interaction logic is in the <see cref="TechMatrixController"/>
    /// </remarks>
    public partial class TechnologyMatrixPart 
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="TechnologyMatrixPart"/> class.
        /// </summary>
        public TechnologyMatrixPart()
        {
            InitializeComponent();
        }

        #region Dependency Property  SaveGame 

        /// <summary>
        /// Dependency property SaveGame
        /// </summary>
        public static readonly DependencyProperty SaveGameProperty =
            DependencyProperty.Register("SaveGame", typeof (SaveGame), typeof (TechnologyMatrixPart), new UIPropertyMetadata(null, OnSaveGameValueChanged));


        /// <summary>
        /// Gets or sets the SaveGame
        /// </summary>
        /// <value>The value.</value>
        public SaveGame SaveGame
        {
            get { return (SaveGame) GetValue(SaveGameProperty); }
            set { SetValue(SaveGameProperty, value); }
        }

        #endregion

        /// <summary>
        /// Change something, when the value of the dependency property SaveGame
        /// </summary>
        /// <param name="d">instance of TechnologyMatrixPart</param>
        /// <param name="e">the new and old values</param>
        private static void OnSaveGameValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TechnologyMatrixPart o = (TechnologyMatrixPart) d;
            TechMatrixController matrixController = (TechMatrixController) o.DataContext;
            matrixController.Game = (SaveGame) e.NewValue;
        }
    }
}